import {
  webviewTarget,
  webviewProperties,
  webviewMethods,
} from "./webview-binders";

@webviewTarget("context2D")
@webviewProperties({
  fillStyle: "#000",
  font: "10px sans-serif",
  globalAlpha: 1.0,
  globalCompositeOperation: "source-over",
  lineCap: "butt",
  lineDashOffset: 0.0,
  lineJoin: "miter",
  lineWidth: 1.0,
  miterLimit: 10.0,
  shadowBlur: 0,
  shadowColor: "rgba(0,0,0,0)",
  shadowOffsetX: 0,
  shadowOffsetY: 0,
  strokeStyle: "#000",
  textAlign: "start",
  textBaseline: "alphabetic",
})
@webviewMethods([
  "arc",
  "arcTo",
  "beginPath",
  "bezierCurveTo",
  "clearRect",
  "clip",
  "closePath",
  "createImageData",
  "createLinearGradient",
  "createPattern",
  "createRadialGradient",
  "drawFocusIfNeeded",
  "drawImage",
  "drawWidgetAsOnScreen",
  "drawWindow",
  "ellipse",
  "fill",
  "fillRect",
  "fillText",
  "getImageData",
  "getLineDash",
  "isPointInPath",
  "isPointInStroke",
  "lineTo",
  "measureText",
  "moveTo",
  "putImageData",
  "quadraticCurveTo",
  "rect",
  "restore",
  "rotate",
  "save",
  "scale",
  "setLineDash",
  "setTransform",
  "stroke",
  "strokeRect",
  "strokeText",
  "transform",
  "translate",
])
export default class CanvasRenderingContext2D {
  constructor(canvas) {
    this.canvas = canvas;
  }

  postMessage(message) {
    return this.canvas.postMessage(message);
  }
}
